function DashboardAssistant(type, icon, title, message, calendarEvent){
	Mojo.Log.info('--- BEGIN DashboardAssistant(), icon: ' + icon + ', title: ' + title);
	
	this.type = type;
	this.icon = icon;
	this.title = title;
	this.message = message;
	this.calendarEvent = calendarEvent;
}

DashboardAssistant.prototype.setup = function() {
	Mojo.Log.info("--- BEGIN DashboardAssistant.setup(), type: ", this.type);
	try {
		if (this.type == 'preferences') {
			this.tapEventOpenPreferencesHandler = this.openPreferences.bindAsEventListener(this);
			this.controller.listen("dashboardinfo", Mojo.Event.tap, this.tapEventOpenPreferencesHandler);
		}
		else if (this.type == 'calendarEvent') {
			this.tapEventOpenCalendarEventHandler = this.openCalendarEvent.bindAsEventListener(this);
			this.controller.listen("dashboardinfo", Mojo.Event.tap, this.tapEventOpenCalendarEventHandler);
		}
	} catch (e) {
		Mojo.Log.error("DashboardAssistant.prototype.setup", e);
	}
}

DashboardAssistant.prototype.activate = function(event) {
	Mojo.Log.info("--- BEGIN DashboardAssistant.activate()");
	try {
		this.update();
	} catch (e) {
		Mojo.Log.error("DashboardAssistant.prototype.activate", e);
	}
}

DashboardAssistant.prototype.cleanup = function(event) {
	Mojo.Log.info("--- BEGIN DashboardAssistant.cleanup()");
	try {
		if (this.type == 'preferences')  {
			this.controller.stopListening("dashboardinfo", Mojo.Event.tap, this.tapEventOpenPreferencesHandler);
			// Close all stages
			Mojo.Controller.getAppController().closeAllStages();
		}
		else if (this.type == 'calendarEvent') {
			Mojo.Log.info("--- BEGIN DashboardAssistant.cleanup(): calendarEvent stop listening");
			this.controller.stopListening("dashboardinfo", Mojo.Event.tap, this.tapEventOpenCalendarEventHandler);
		}
		Mojo.Log.info("--- END DashboardAssistant.cleanup()");
	} catch (e) {
		Mojo.Log.error("DashboardAssistant.prototype.cleanup", e);
	}
}

DashboardAssistant.prototype.update = function() {
	Mojo.Log.info("--- BEGIN DashboardAssistant.update()");
	
	try {
		var info = {
			icon:		this.icon,
			title:		this.calendarEvent ? this.calendarEvent.getDashboardTitle() : this.title,
			message:	this.calendarEvent ? this.calendarEvent.subject : this.message
		};
		var renderedInfo = Mojo.View.render( {
			object:		info,
			template:	'dashboard/dashboard-item'
		});
		var dashboard = this.controller.get('dashboardinfo');
		dashboard.innerHTML = renderedInfo;
	} catch (e) {
		Mojo.Log.error("--- ERROR: DashboardAssistant.update", e);
	}
}

DashboardAssistant.prototype.openPreferences = function(){
	Mojo.Log.info("--- BEGIN DashboardAssistant.openPreferences()");
	try {
		Mojo.Controller.getAppController().assistant.openPreferences({});
	} catch (e) {
		Mojo.Log.error("--- ERROR: DashboardAssistant.openPreferences", e);
	}	
}

DashboardAssistant.prototype.openCalendarEvent = function() {
	Mojo.Log.info("--- BEGIN DashboardAssistant.openCalendarEvents()");
	try {
		this.controller.serviceRequest('palm://com.palm.applicationManager', {
		    method: 'launch',
		    parameters:  {
		        id: 'com.palm.app.calendar',
		        params: {
					details : this.calendarEvent.id
		        }
		    }
		});
		
	} catch (e) {
		Mojo.Log.error("--- ERROR: DashboardAssistant.openCalendarEvents", e);
	}
};
